from flask import Flask
from flask import request
from flask import redirect
from flask import make_response
from flask import abort

from flask.ext.script import Manager

app = Flask(__name__)
manager = Manager(app)


@app.route('/')
def index():
    user_agent = request.headers.get('User-Agent')
    return '<h1>%s</h1>' % user_agent

@app.route('/redir')
def redir():
    return redirect('http://zengrong.net')

@app.route('/setcookie')
def setcoookie():
    abort(404)
    response = make_response('<h1>This document carries a cookie!</h1>')
    response.set_cookie('answer', '42')
    return response

@app.route('/user/<name>')
def user(name):
    return '<h1>hello, %s!</h1>' % name

if __name__ == "__main__":
    # app.run(debug=True)
    manager.run()
